﻿using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using System.Data;
using BEGDC.Utility.NHibernate;
using Castle.Services.Transaction;
using System.Collections;
using System.Xml;
using Castle.Facilities.NHibernateIntegration;

namespace BEGDC.PreContract.BLL
{
    [Transactional]
    public partial class ProvinceCluster : IProvinceCluster
    {
        private  ISessionFactory  factory;

        /// <summary>
        /// Initiate session factory.
        /// </summary>
        /// <param name="sessionFactory"></param>
        public ProvinceCluster(ISessionFactory sessionFactory)
        {
            this.factory = sessionFactory;
        }
		
		//Get by id
		[Transaction(TransactionMode.Requires)]
        public BEGDC.PreContract.DAL.ProvinceCluster GetProvince(System.Int32 provinceClusterID)
		{
            BEGDC.PreContract.DAL.ProvinceCluster provinceCluster = BEGDC.PreContract.DAL.ProvinceCluster.TryFind(provinceClusterID);

            return provinceCluster;
		}
		
		//Get by filter
		[Transaction(TransactionMode.Requires)]
        public DataTable GetProvinceCluster_DataTable(string filter)
		{
			using (ISession session = factory.OpenSession())
            {
				string strSql = "SELECT * FROM ProvinceCluster";
				if (filter.Trim() != string.Empty)
					strSql += " WHERE " + filter;

                DataTable dtSearch = DAO.ExecuteDataTable(session, strSql);

                return dtSearch;
            }
		}
		
    }
}
